package example;

/**
 * 括号匹配
 */
public class Task2 {
    public static void main(String[] args) {
        System.out.println(method("()()(()))((())"));
    }

    public static boolean method(String str) {
        int temp = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == '(')
                temp += 1;
            else {
                temp -= 1;
                if (temp < 0)
                    return false;
            }
        }
        return temp == 0;
    }
}
